package com.netty.webSocket;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/**
 * Created by Administrator on 2018/9/9/009.
 */
public class WebSocketServer {
    public static void main(String[] args) {
        EventLoopGroup bossLoop = new NioEventLoopGroup();
        EventLoopGroup workLoop = new NioEventLoopGroup();

        try {
            ServerBootstrap bootStrap = new ServerBootstrap();
            bootStrap.group(bossLoop, workLoop).channel(NioServerSocketChannel.class);
            bootStrap.childHandler(new WebSocketServerInitializer());

            ChannelFuture channelFuture = bootStrap.bind(8899).sync();
            channelFuture.channel().closeFuture().sync();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            bossLoop.shutdownGracefully();
            workLoop.shutdownGracefully();
        }
    }
}
